package com.yuxi.Util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public class MyMd5Util {
	public static String stringToMd5(String str){
		 try {
				MessageDigest md5=MessageDigest.getInstance("MD5");	
				byte[] md=md5.digest(str.getBytes("utf-8"));
				BASE64Encoder base64en = new BASE64Encoder();			
				return base64en.encode(md);			
			} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
				e.printStackTrace();
				return "";
			}		 
	}
}
